GBML manual / Engine

Budgets

The real, fixed limits of the hardware a project runs on, and how the editor and the debug overlay show them.

These numbers are not settings

Every limit on this page is a fact about the Game Boy Advance itself, not a configuration value a project can turn up. Nothing in Gbabel raises one of these to make a room fit - the fix for a room that does not fit is always to use less of the resource, never to ask the hardware for more of it than it has.

ResourceLimitWhat happens past it
Sprites drawn in one frame128the hardware itself will not draw any more - not a soft warning
Sprites that can exist at once, hidden included192reserved up front; a hidden sprite still holds its slot
Distinct sprite tile sets held at once, hidden included128the pool itself refuses to create another - a hard assert, not a graceful skip
Ordinary backgrounds visible at once4, or 2 in a room with a zoomable backgroundthe console's display mode counts the zoomable pictures on screen, and a mode with one has only two ordinary layers
Tiles in a zoomable background256 differentits map has one byte for each cell
Tiles in one background1,024a 10-bit tile index; this is a hard ceiling on one background's own tile set
Affine matrices alive at once (anything rotated or scaled)32counted across everything alive at the same moment, not a project-wide total
Sprite palette banks alive at once (16 colors each)16same same-moment counting as affine matrices
Background palette banks alive at once (16 colors each)16a separate pool from sprite palettes; a picture or a tileset drawn with several palettes takes one for each (One picture, several palettes)
EWRAM256 KBgeneral working memory
IWRAM32 KBfast memory; shared with the call stack
ROM32 MBthe cartridge itself
SRAM (save memory)32 KBbattery-backed, survives power-off

The engine's own tables are different

More limits are not facts about the console. They are sizes the engine chose for its own tables: how many animated tile groups a game can have, the biggest room whose tiles can change, how many things your code can draw at once, how many fonts, lights, paused tilesets and tweens, how many particles, running effects and cutscene steps, and how many input actions. A game can change these in Project Settings, under Engine limits, and gives memory back by lowering them or gets room by raising them: Project settings has the table, what each costs and what happens when it is too small. Moving one never moves a number in the table above.

Two of the Budgets panel's gauges read the project's own choice and not a fixed number: Animated tiles (busiest room) counts the animated tile groups of the room that has the most against the number a room allows, yellow when there is no room for another and red over it; a built game's debug overlay has a matching TILEANIM row.

The engine sizes its other tables to your game

Some of the engine's tables are not set by you at all: the build works out the size from what the game can use and reserves no more. The editor's memory figure counts the same numbers.

Some tables stay the same size in every game because the build cannot know how many will be needed: the things your game draws at once (a frame can ask for as many as its code asks for), the effects that change the screen row by row, the console library's sprite and tile pools, and the save store, whose size is part of the save file. They are the ones you can change in Engine limits and Memory pools.

"Alive at the same moment", not "used anywhere in the project"

The affine matrix and palette bank limits are the two easiest to misjudge, because they are not a total across your whole project - they are a count of what is actually alive on screen at once, in the worst room, at the worst moment. A project can use forty different palettes across its whole run without ever breaking the 16-bank limit, as long as no single moment needs more than 16 of them alive together. This is also exactly why hiding something is not the same as it costing nothing: a hidden sprite (visible = false) still holds its palette bank and its pool slot, it just is not drawn - only actually destroying an instance frees what it was holding.

A turned, enlarged or leaned sprite is drawn into a bigger box

The console cuts a sprite off at its own edges, unless it is told to draw it into a box twice as wide and twice as tall. A picture that is turned, made bigger or leaned (angle, xscale, xshear) can stick out past its own edges, so Gbabel asks for the bigger box whenever that could happen: when the picture is enlarged, leaned, or turned and not shrunk. A picture that only gets smaller never needs it and never gets it.

(The Game Boy Advance module can choose this for itself, and it does, with one gap: it misses a picture that sticks out by less than one pixel. A 32 pixel sprite turned by a quarter of a degree, or made 2 percent bigger, lost its right-hand and bottom row of pixels. Gbabel checks for that case itself, so no edge pixels are lost.)

Two things follow, and both come from the console, not from Gbabel:

Every object declares its own ceiling

Objects and instances covers this from the language side: every object states the most instances of it that may exist at once, and that number is reserved as real memory up front, not grown as instances appear. Each of those slots also carries a 40-byte note of how its instance looked the last time it was drawn - where it was, which picture it showed, which way it faced, and a few other things. When nothing in the note has changed, the engine does not redraw that instance at all, which is why a room full of walls that never move costs a fraction of what it used to. So an object whose maximum is 100 instances reserves 4,000 bytes for these notes on top of the instances themselves (each holds only the built-in parts its object uses: see Objects and instances). (Building with --draw-skip=off turns the skipping off and gives that memory back.) For a real project, the editor turns what is actually placed into a per-room estimate against the hardware ceilings above - and is honest about the two different kinds of number that come out of that. A room's distinct placed sprites become an upper bound on sprite palette banks: never wrong in the low direction, since several sprites can share one bank but none ever needs more than one, so it only ever warns once that bound clears 16 - never a hard refusal. Background palette banks, backgrounds and affine matrices get no such estimate at all: nothing about what is merely placed tells you what those will actually cost, so the editor shows them as unknown rather than guess.

There is one exception, and it is the reason the number of ordinary background layers is not always 4. A room can opt in to a zoomable background, a picture the hardware can zoom and turn, and a room that has one can show only 2 ordinary layers. What a room itself puts on its layers (its floor, its shroud, the text box of a cutscene that starts there) is known from what you placed, so for that one resource the Budgets panel's BG layers (room) gauge is a real count, drawn against the limit of the room it is looking at: 2 for a room with a zoomable background and 4 for one without. What your code makes with background_create is still not counted, in either kind of room. That count can stop a build in exactly one case: a room with a zoomable background that certainly needs more than two layers (a floor, a shroud and a cutscene text box, say) is an error, because something it draws would not appear.

Otherwise, none of this - the palette warning, or the silence on the rest - ever blocks an export or a build. The one build-time check today compares each object's own declared maximum instances against the project's own declared instance-pool setting: a self-consistency check on the project's own numbers, not a measurement against real hardware, and a warning even then. A true hardware-budget gate is a named goal, not something built yet - which is exactly why the next two sections matter.

instance_create is invisible to all of this

Every estimate above starts from what a room actually places. instance_create is ordinary GBML code, not room data - the same category as a rotation or scale set in any event - and none of that is anything a pass over the project's own files can run ahead of time. An object that is never placed anywhere, only ever spawned by another object's own code, contributes to no room's estimate at all: not to the sprite palette upper bound above, not to anything else, because there was nothing placed to count. This is the one way a project can pass every gauge the editor shows and still exceed real hardware the moment it actually runs - and not a gap a smarter gauge closes either: what instance_create does can depend on anything decided at runtime (a save value, an enemy count, a frame number), so no static pass over the source can promise it has seen every instance a room will ever hold.

Three habits keep this from ever being a surprise:

Where the numbers actually come from

engine/include/gbml/config.h holds the base capacities every project starts from. Many of them a project can change: its own generated header (gbml_project_format.h, written by the build from Project Settings, under Engine limits) overrides them where a specific project genuinely needs a different balance - always trading one thing for another within the same hardware ceiling above, never past it. The rest stay what the engine and the console make them.

Checking it while the game is actually running

A debug overlay shows the same numbers the editor estimates at build time, but live and measured rather than guessed: sprites, sprite pool objects, matrices, both palette pools, backgrounds, instances per object, the draw cache, and the frame's own time, each with its peak value alongside the current one - read straight from the Game Boy Advance module's own counters, the same ones a real cartridge runs on. Press your project's debug chord in a built ROM to toggle it. The chord is L, R and Select until you pick another in Project Settings (Project settings says how). This overlay is where the cost instance_create puts beyond the editor's reach becomes visible again.

The overlay is part of every Build & Play ROM unless you say otherwise. A Release Build leaves it out unless you tick Keep the debug overlay in the finished game. Untick Ship the debug overlay in my ROM in Project Settings (Project settings) and the finished game does not contain it at all: it takes no room in the game and the button chord does nothing.

It does not show everything: the sprite tile set pool (above) has no row here either, which is exactly why it was the one resource that already broke a real build in this project without any gauge - static or live - ever getting a chance to warn about it first.

What goes into the ROM covers reachability and finished size today; live hardware-budget peaks in that same report are a named goal but not built yet, which leaves the debug overlay above as the only place the true, live numbers exist right now.

See also: Where the machine shows throughObjects and instancesRoomsinstance_createWhat goes into the ROM, and how to pin something